const Models = require('./../../models')

class Informat{
    static async getData(ctx){
        console.log(1)
        const userData =await Models.users.findAll();
        const noUseCar = await Models.cars.findAll({
            where: {
                isUse: true
            }
        })
        const useCar = await Models.cars.findAll({
            where: {
                isUse: false
            }
        })
        await Models.informats.update({total: userData.length,carAmount: noUseCar.length,leaseAmount: useCar.length},{
            where: {
                id: 1
            }
        })
        const data =await Models.informats.findOne({
            where: {
                id: 1
            }
        })
        ctx.response.status = 200;
        ctx.response.body = {
            code: 200,
            msg: '请求成功',
            data
        }
    }
}

module.exports = Informat